{% import 'macro.html.twig' as web_macro %}
{% set questionTypesDict = getQuestionTypes() %}
<table class="table table-striped table-hover" id="quiz-table">
  <thead>
  <tr>
    <th><input type="checkbox" autocomplete="off" class="js-select-all"></th>
    <th width="25%">{{'course.question_manage.stem'|trans}}</th>
    <th width="15%">{{'course.question_manage.type'|trans}}</th>
    <th width="15%">{{'course.question_manage.manage.difficulty'|trans}}</th>
    <th>{{'course.question_manage.update'|trans}}</th>
    <th width="20%">{{'course.question_manage.operation'|trans}}</th>
  </tr>
  </thead>
  <tbody>
    {% for question in questions %}
      <tr data-role="item">
        <td><input value="{{question.id}}" data-id="{{question.id}}" type="checkbox" autocomplete="off" class="js-checkbox"></td>
        <td>
          <a class="color-info" href="#modal" data-toggle="modal" data-url="{{  path('question_bank_manage_question_preview', {id: questionBank.id, questionId: question.id}) }}">
            {% if question.includeImg|default(null) %}<span class="glyphicon glyphicon-picture"></span>{% endif %}
            {{ question.material |fill_question_stem_text| plain_text(30) }}
            <br/>
            <span class="color-gray text-sm">{{ 'category'|trans }}：
              {% if question.category_id %}
                {{ questionCategories[question.category_id].name }}
              {% else %}
                {{ 'site.data.empty'|trans }}
              {% endif %}
            </span>
          </a>
          <div>
            {% if question.type == 'material' and not question.question_num %}
              <span class="label label-danger">{{'course.question_manage.question.unfinished'|trans}}</span>
            {% endif %}
          </div>
        </td>
        <td>
          {{ questionTypesDict[question.type] }}
          {% if question.type == 'material'%}
            <br><small class="color-gray">({{ question.question_num }}{{'course.question_manage.question.sub_question'|trans}})</small>
          {% endif %}
        </td>
        <td>
          {% if question.difficulty == 'simple' %}
            {{ 'course.question_manage.manage.easy_difficulty'|trans }}
          {% elseif question.difficulty == 'normal' %}
            {{ 'course.question_manage.manage.normal_difficulty'|trans }}
          {% else %}
            {{ 'course.question_manage.manage.hard_difficulty'|trans }}
          {% endif %}
        </td>
        <td>
          {{ web_macro.user_link(users[question.updated_user_id]) }}
          <br />
          <span class="color-gray text-sm">{{question.updated_time | date('Y-n-d H:i:s')}}</span>
        </td>
        <td>
          <div class="btn-group">
            <a  href="javascript:" class="color-info js-update-btn" data-url="{{ path('question_bank_manage_question_update', {id:questionBank.id, questionId:question.id, goto: paginator.getPageUrl(paginator.currentPage)}) }}"  class="color-info"> {{'course.question_manage.question.edit_btn'|trans}}</a>
            <a href="javascript:" class="color-info js-delete-btn" data-name='{{'course.question_manage.question'|trans}}'
            data-url="{{ path('question_bank_manage_question_delete', {id: questionBank.id, itemId: question.id}) }}">
              {{'course.question_manage.question.delete_btn'|trans}}
            </a>
          </div>
        </td>
      </tr>
    {% else %}
      <tr>
        <td colspan="20"><div class="empty">{{'course.question_manage.empty'|trans}}</div></td>
      </tr>
    {% endfor %}
  </tbody>
</table>
<div>
  <label class="checkbox-inline"><input type="checkbox" autocomplete="off" class="js-select-all"> {{'course.question_manage.select_all'|trans}}</label>
  <span class="color-gray mlm vertical-middle">{{ 'my.teaching.question_bank.question.selected'|trans }}：<span class="js-select-number">0</span></span>
  <button class="cd-btn cd-btn-default cd-btn-sm mlm js-batch-delete" data-name="{{'course.question_manage.question'|trans}}" data-url="{{ path('question_bank_manage_question_batch_delete', {id: questionBank.id}) }}" data-loading-text="{{'form.btn.delete.submiting'|trans}}">{{'form.btn.delete'|trans}}</button>
  <button class="cd-btn cd-btn-default cd-btn-sm mlm js-batch-set" data-name="{{'course.question_manage.question'|trans}}" data-url="" data-loading-text="{{'form.btn.save.submiting'|trans}}">{{'my.teaching.question_bank.question.set_category'|trans}}</button>
  <span class="pull-right color-gray">{{'course.question_manage.count'|trans({'%getItemCount()%': paginator.getItemCount() })}}</span>
</div>
<nav class="text-center">
  {{ web_macro.ajax_paginator(paginator) }}
</nav>